package com.liqiye.paymanager.service.common.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liqiye.paymanager.bean.payment.PaymentRequest;
import com.liqiye.paymanager.entity.StripeIntent;
import com.liqiye.paymanager.mapper.StripeIntentMapper;
import com.liqiye.paymanager.service.common.StripeIntentService;
import com.stripe.model.PaymentIntent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class StripeIntentServiceImpl extends ServiceImpl<StripeIntentMapper, StripeIntent> implements StripeIntentService {

    @Autowired
    private StripeIntentMapper stripeIntentMapper;

    public void createIntent(PaymentIntent intent, PaymentRequest req){
        StripeIntent stripeIntent = new StripeIntent();
        stripeIntent.setId(intent.getId());
        stripeIntent.setOrderId(req.getOrderId());
        stripeIntent.setUpdateTime(new Date());
        stripeIntentMapper.insert(stripeIntent);
    }

}
